% 根据调度方案绘制甘特图
clc;
clear;  
A= [5	3	3	0	1	33	36
   4	3	3	36	39	84	85
   2	2	2	0	1	67	71
   1	1	1	0	3	80	84
   3	3	3	85	88	128	129]
schedule=A
figure;
Job=max(schedule(:,1));
Machinedis=max(schedule(:,2));
ylim([0 4]);
row=size(schedule,1);
%eachcolors=[0 0.80784 0.81961];
 eachcolors1=[0.74118 0.71765 0.41961];
%eachcolors2=[0 0.80784 0.81961];
for i=1:row
    X=[schedule(i,4) schedule(i,5)];
    now=schedule(i,3)
    Y=[now now]
 %  line(X,Y,'LineWidth',30,'color',eachcolors);
  line(X,Y,'LineWidth',25,'color',[0.8500 0.3250 0.0980])
end
for i=1:row
     X=[schedule(i,5) schedule(i,6)];
    now=schedule(i,3)
     Y=[now now]
%line(X,Y,'LineWidth',25,'color',eachcolors1);
line(X,Y,'LineWidth',25,'color',[0.9290 0.6940 0.1250])
end 
for i=1:row
     X=[schedule(i,6) schedule(i,7)];
    now=schedule(i,3)
     Y=[now now]
%	line(X,Y,'LineWidth',30,'color',eachcolors2);
line(X,Y,'LineWidth',25,'color',[0 0.4470 0.7410])
end 
for  i=1:row
    X=schedule(i,5:6)
txt=[num2str(schedule(i,1))];
   now=schedule(i,3)
text( mean(X), now,txt,"FontName","Times New Roman","FontSize",15,"LineWidth",20)
end
yticks(1:4);
ytickTxt=cell(1,4);
ytickTxt(1)={['M' num2str(1) '-' num2str(1)] };
ytickTxt(2)={['M' num2str(2)] };
ytickTxt(3)={['M' num2str(3)] }% '-' num2str(1)] };
%ytickTxt(4)={['M' num2str(3) ] }%'-' num2str(1)] };
yticklabels( ytickTxt);
%title('The Scheduling Result')
%xlabel('Processing Time')
%ylabel('Processing Machine')
title('切割调度结果')
xlabel('加工时间')
ylabel('加工机器')